/*
 * Copyright (c) 2024 iSOFT INFRASTRUCTURE SOFTWARE CO., LTD.
 * easyAda is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */

#ifndef CAPS_ADDRSPACE_H
#define CAPS_ADDRSPACE_H

#include <core/addrspace.h>
#include <caps/capability.h>

static inline addrspace_t *cap_addrspace_get_obj(capability_t *cap)
{
    return (addrspace_t *)cap_get_long_info(cap);
}

static inline void cap_addrspace_put(capability_t *cap)
{
    assert(cap != 0 && cap_get_type(cap) == CAP_ADDRSPACE);
    addrspace_put(cap_addrspace_get_obj(cap));
}

int cap_addrspce_map(capability_t *cap, unsigned long begin, unsigned int size);

void cap_addrspace_init(capability_t *cap, addrspace_t *as);

#endif
